Skip to main content
info

This page is currently under construction - it will be completed soon!

caution

Our 'Advanced Notifications' functionality requires that we send data from PI AF to our provider's email server in the United States. If a customer has a strict requirement for their operational data to stay in a certain geographic region, we may not be able to offer this feature to them.

Summarising how many results have exceeded pre-configured limits

USR Setup​

  • Convert the timestamp of the individual time-series event, to Epoch time
  • Write that value to a tag where the tagname is the same as the actual parameter being measured, with a '.String' prefix on the end
  • Ensure a performance point is writing the total number of values that have been processed by the USR (don't double-count the Value and the String events)

AF Setup​

Need certain config in the element template's attributes, element template's analyses, and in the actual AF hierarchy itself.

AF Element Template Setup​

The elements that represent the results of the file, should have templated attributes which point to:

  • the normal parameter tag,
  • the additional '.String' tag, and
  • a shared tag to store the total number of exceedances in a given area/location.

AF Element Analyses Template Setup​

The elements that represent the results of the file, should have templated analyses which:

  • Compare the result from the 'Value' tag, to each set of upper and lower limits. To each limit, it writes a '1' if limit is exceeded, or '0' if result is in-spec. The analysis should be event-triggered by the value tag, and use automatic recalculation. Output time is default a.k.a. 'Trigger Time'.
  • Compare the result from the 'String' tag, to each set of upper and low limits. Counts the total number of exceedances across all limits, and writes the value to the 'Shared' tag. The analysis should be event-triggered by the '.String' tag. Output time is 'Execution Time'.

AF Hierarchy Structure​

At the level above the measurements themselves, the element should have

  • attributes pointing to the USR's 'Events Processed' performance point, and the 'Shared' tag.
  • an analysis which generates an event frame. The analysis should be triggered every 5/15/30 minutes as appropriate. It should check that the EventCount in the 'Events Processed' performance point is > 0, and immediately close. It can write the 'Events Processed' value to the resultant event frame (as the frame is immediately closed), and can TagTot all of the values of the last 5/15/30 minutes from the 'Shared' tag.

SendGrid Integration​

To create an email, an appropriate email template must be created in SendGrid, and the AF system must send a notification (with event frame data) to the SendGrid REST API.

SendGrid Template​

AF Notification​

Ensure the 'Delivery Channel' exists for SendGrid. In PI System Explorer, go to 'Contacts' and expand the 'Delivery Endpoints' folder. If there is no endpoint related to SendGrid, right-click and click 'New Delivery Endpoint'. The delivery channel should be WebService, style should be REST, method should be POST, and the URL should be https://api.sendgrid.com/v3/mail/send. Authentication should be 'Anonymous' as we will specify the authentication using a custom header.

At the level above the measurements themselves, add a new notification rule. The trigger rule should be 'Event Frame Search', and the template should be whatever kind of event frame you have configured to store the TagTot from the 'Shared' tag.

On the notification rule, click the 'View/Edit Subscriptions' button. Under 'Delivery Endpoints', drag the SendGrid endpoint into the main portion of the window. Ensure the 'Notify Option' is 'Event End'. Click the spanner icon to begin adding content to the POST request that is sent to SendGrid when the event frame is closed.

In the 'Body' tab, some Path items and values are mandatory:

  • template_ID
  • from.email
  • asm.group_ID
  • personalizations[0].to[0].email

All other dynamic content can be listed using the syntax personalizations[0].dynamic_template_data.DYNAMIC_ITEM as a Path, substituting DYNAMIC_ITEM for whatever it is known by in the SendGrid template. The values for each path item, can be typed by text, or dragged over from the 'Event Frame attributes' menu.

Sending dynamic content from AF to the SendGrid platform

Once complete, click the 'Headers' tab. Two items are mandatory:

  • Content-Type (value should be application/json)
  • Authorization (value should be SENDGRID_API_KEY_HERE)

Once done, check everything in and the pipeline from file processing to email notification is ready.